#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc,char* argv[])
{
    printf("process is running....\n");
    pid_t id = fork();
    if(id == 0)
    {
        sleep(1);
        execvp(argv[1],&argv[1]);
        //execl("/usr/bin/ls","ls","-a","-l","--color=auto",NULL);
        //execlp("ls","ls","-a","-l","--color=auto",NULL);
       // char* const argv_[] ={
       //     "ls",
       //     "-a",
       //     "-l",
       //     "--color=auto",
       //     NULL
       // };
       // execvp("ls",argv_);
       //execl("./mycpp","mycpp",NULL);
     
       // char* const envp_[] = {
       //     "MYENV=112233445566"
       // };
       // execle("./mybin","mybin",NULL,envp_);
       //putenv((char*)"MYENV=443322111");
       //extern char** environ;
       //execle("./mybin","mybin",NULL,environ);
        exit(1);
    }
    int status = 0;
    pid_t ret = waitpid(id,&status,0);
    if(ret > 0)
    {
        printf("wait success exit code: %d,sig :%d\n",(status>>8)&0xFF,status &0x7F);
    }

   // printf("procee is running\n");

   // //加载程序！
   // execl("/usr/bin/ls"/*找到程序*/,"ls","--color=auto","-a","-l",NULL);
   // //所有exec的接口都必须以NULL结尾！表示传参结束！


   // printf("process is done\n");
   // exit(1);
}

